'''
Created on 15/02/2010

@author: eh01
'''
from httpserver import MyHTTPServer
from optparse import OptionParser
import os
import sys

if __name__ == '__main__':
    parser = OptionParser(usage=u"%s options." % sys.argv[0])

    parser.add_option("--host",
    dest=u"host", help=u"Host name of server.")
    
    parser.add_option("--port", type="int", 
    dest=u"port", help=u"Port of server")    
    
    # because I dont know how to get the hostname and the port of 
    # the network interface, it must be specified through params
    parser.add_option("--nport",
    dest=u"nport", help=u"Port of network interface.")      
    
    parser.add_option("--nhost",
    dest=u"nhost", help=u"Host name of network interface.")  

    (options, args) = parser.parse_args()
    options.script = os.path.split(sys.argv[0])[1]
    
    try:
        server = MyHTTPServer(options.host, options.port, options.nhost, options.nport)
        print 'started server'
        server.serve_forever()        
    except KeyboardInterrupt:
        server.shutdown_server()